package org.come.Jpanel;

import com.tool.btn.FormsOnOffBtn;
import com.tool.btn.PetPanelBtn;
import com.tool.image.ImageMixDeal;
import com.tool.tcp.NewPart;
import com.tool.tcpimg.UIUtils;
import org.come.entity.RoleSummoning;
import org.come.until.AnalysisString;

import javax.swing.*;
import java.awt.*;

public class HuaLianJpanel extends JPanel {

    private RoleSummoning pet;
    private PetPanelBtn btnHuaLian;// 化莲

    public HuaLianJpanel() {
        this.setLayout(null);
        this.setPreferredSize(new Dimension(414, 416));
        this.setBackground(new Color(0, 0, 0, 0));
        FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/button/1.png", 1, 701);
        offBtn.setBounds(414 - 33, 10, 25, 25);
        this.add(offBtn);

        btnHuaLian = new PetPanelBtn("inkImg/button/B410.png", 1, UIUtils.COLOR_BTNPUTONG, UIUtils.HYXLSJ17, "化莲", 15, this);
        btnHuaLian.setBounds(180, 365, 59,26);
        this.add(this.btnHuaLian);
    }



    private NewPart part;
    public void updatePet(RoleSummoning pet){
        this.pet = pet;
        if (pet != null) {
            part = pet.getPart();
        } else {
            part = null;
        }
    }

    private ImageIcon icon;
    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        if (this.icon == null) {
            this.icon = new ImageIcon("inkImg/background/S320.png");
        }
        g.drawImage(this.icon.getImage(), 0, 0, 414, 416, this);
        if (pet != null) {
            g.setColor(Color.GREEN);
            g.setFont(UIUtils.TEXT_BOLD_FONT);
            g.drawString(pet.getSummoningname(),195,70);

            g.setColor(Color.WHITE);
            g.setFont(UIUtils.TEXT_FONT78);
            g.drawString("等级>=1转120级",110,250);
            g.drawString("亲密>=200,000",110,280);

            Integer grade = pet.getGrade();
            Long qm = pet.getFriendliness();
            if (grade >= 221 && qm >= 200000) {
                g.setColor(Color.GREEN);
            } else {
                g.setColor(Color.RED);
            }
            g.drawString("当前"+ AnalysisString.petLvl(grade)+"级",250,250);
            g.drawString("当前"+qm,250,280);
        }
        if (part != null) {
            part.draw(g, 220, 190, 0, ImageMixDeal.userimg.getTime());
        }
    }

    public RoleSummoning getPet() {
        return pet;
    }

    public void setPet(RoleSummoning pet) {
        this.pet = pet;
    }
}
